package com.zhxs.utils;

import android.app.AlarmManager;
import android.content.Context;

import java.util.Calendar;

public class DateUtils {
    private static final long MIN_DATE = 1194220800000L;
    public static void setDate(Context context, int year, int month, int day) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month);
        c.set(Calendar.DAY_OF_MONTH, day);
        long when = Math.max(c.getTimeInMillis(), MIN_DATE);
        if (when / 1000 < Integer.MAX_VALUE) {
            ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).setTime(when);
//            SystemClock.setCurrentTimeMillis(when);
            LogUtil.i("DateUtils", "设置系统时间成功"+when);
        }
    }
}
